package com.example.demo;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

@ResponseBody
@ControllerAdvice
public class ExDeal {
//    @ExceptionHandler(ArithmeticException.class)
//    public HashMap<String, String> arithmeticException(ArithmeticException e) {
//        HashMap<String, String> result = new HashMap<>();
//        result.put("code", "-1");
//        result.put("msg", "算术异常异常：" + e.getMessage()); // 错误码的描述信息
//        result.put("data", "除数不能为0");
//        return result;
//    }
//@ExceptionHandler(Exception.class)
//public HashMap<String, Object> exception(Exception e) {
//    HashMap<String, Object> result = new HashMap<>();
//    result.put("code", "-1");
//    result.put("msg", "算术异常" );
//    result.put("data", "除数不能为0");
//    return result;
//}
}
